{smcl}
{* *! version 1.0.0 15april2016}{...}
{cmd:help bsurvci}{right: ({browse "https://doi.org/10.1177/1536867X19830915":SJ19-1: st0553})}
{hline}

{title:Title}

{p2colset 5 16 18 2}{...}
{p2col:{hi:bsurvci} {hline 2}}Calculate bootstrap pointwise confidence intervals for survival curves from stcox{p_end}


{marker syntax}{...}
{title:Syntax}

{p 8 15 2}
{cmdab:bsurvci} {ifin}{cmd:,} {cmdab:gen:erate}{cmd:(}{it:newvar}{cmd:)}
{cmd:at}[{it:#}]{cmd:(}{it:varname} {it:#} [{varname} {it:#} ...]{cmd:)} 
{cmd:id}{cmd:(}{it:varname}{cmd:)}
[{opt tvc(varlist)}
{opt texp(string)}
{cmd:replace}
{opt ties(stcox_ties)}
{opt shared(varname)}
{opt strata(varname)}
{opt r:eps(#)}
{opt level(#)}
{opt graph}
{opt plotopts(options)}]


{marker description}{...}
{title:Description}

{pstd}
{cmd:bsurvci} fits {cmd:stcox} and uses the bootstrap to calculate the
pointwise confidence intervals of the survival curve for specific covariate
values.


{marker options}{...}
{title:Options}

{phang}
{opt generate(newvar)} creates the variable {it:newvar} to store the estimated
survival curve and creates {it:newvar}{cmd:_lb} and {it:newvar}{cmd:_ub} to
store the respective upper and lower bounds.  If you also specify
{cmd:strata()}, then {cmd:bsurvci} creates variables for each stratum.
{cmd:generate()} is required.

{phang}
{cmd:at}[{it:#}]{cmd:(}{it:varname #} [{it:varname #} ...]{cmd:)} specifies
the covariates included in the model and the values for which the survival
curve should be calculated.  Specifying {cmd:at1()}, [{cmd:at2()}], etc.,
allows one to calculate results for up to four covariate constellations
simultaneously.  Specifying either {cmd:at()} or {cmd:at1()} is required.

{phang}
{opt id(varname)} specifies an ID variable to ensure that multiple-record data
are treated as one subject when the bootstrap is performed.  {cmd:id()} is
required.  For single-record data, one can create an ID variable using
{cmd:generate id_var=_n}.

{phang}
{opt tvc(varlist)} specifies covariates with time-varying coefficients.  The
variables in {cmd:tvc()} must also appear in {cmd:at()}.  {cmd:scurve_tvc}
will automatically {cmd:stsplit} the data at failure times to ensure a
correctly fit model.  See {help tvc note} for more information.

{phang}
{opt texp(string)} specifies the function of analysis time according to which
the effect varies with time.  For example, specifying {cmd:texp(ln(_t))} would
cause the variables with time-varying coefficients to be multiplied by the
logarithm of analysis time.  If {cmd:tvc()} is specified, {cmd:texp()} is
required.

{phang}
{opt replace} specifies to replace the existing variable or variables with the
new estimates.

{phang}
{opt ties(stcox_ties)} specifies how {cmd:stcox} handles tied failure times.
See {manhelp stcox ST} for details.

{phang}
{opt shared(varname)} specifies a shared-frailty ID variable.  See 
{manhelp stcox ST} for details.

{phang}
{opt strata(varname)} specifies a strata ID variable.  See {manhelp stcox ST}
for details.

{phang}
{opt reps(#)} specifies the number of bootstrap replications to be performed.
The default is {cmd:reps(1000)}.

{phang}
{opt level(#)} sets the confidence level.  The default is {cmd:level(95)}.

{phang}
{opt graph} plots the predicted survival curve.  If you also specify
{cmd:strata()}, then {opt graph} plots the survival estimates for each
stratum.

{phang}
{opt plotopts(options)} customizes the plot by using options allowed with
{manhelp graph_twoway_line G-2:graph twoway line}.


{marker example}{...}
{title:Example}

{phang}
{cmd:. webuse catheter}{p_end}
{phang}
{cmd:. generate id=_n}{p_end}
{phang}
{cmd:. stset time, failure(infect) id(id)}{p_end}
{phang}
{cmd:. bsurvci, generate(scurve) at(female 0 age 43) id(id) graph}{p_end}
{phang}
{cmd:. twoway rcap scurve_lb scurve_ub _t, xtitle("Analysis time") lcolor(gs10) legend(order(2 1) label(2 "survival estimate") label(1 "95% CI")) || line scurve _t, sort c(J) lcolor(blue)}{p_end}


{title:Author}

{pstd}Constantin Ruhe{p_end}
{pstd}Institute of Political Science{p_end}
{pstd}Faculty of Social Sciences{p_end}
{pstd}Goethe University Frankfurt{p_end}
{pstd}Frankfurt a. M., Germany{p_end}
{pstd}Ruhe@soz.uni-frankfurt.de{p_end}


{marker also_see}{...}
{title:Also see}

{p 4 14 2}
Article:  {it:Stata Journal}, volume 19, number 1: {browse "https://doi.org/10.1177/1536867X19830915":st0553}{p_end}
